package com.sskj.run.presenter;

import com.lzy.okrx2.adapter.FlowableBody;
import com.sskj.common.base.HttpData;
import com.sskj.lib.bean.PageBean;
import com.sskj.lib.http.JsonConverter;
import com.sskj.run.bean.MyGuessBean;
import com.sskj.run.ui.fragment.MyGuessHistoryFragment;

import java.util.ArrayList;
import java.util.List;

import io.reactivex.Flowable;


public class MyGuessHistoryFragmentPresenter extends BasePresenter<MyGuessHistoryFragment> {

    /**
     * 我的竞猜列表
     */
    public Flowable<List<MyGuessBean>> getMyGuessList(int page, int size) {
        return httpService.myGuessList(page, size)
                .converter(new JsonConverter<HttpData<PageBean<MyGuessBean>>>() {
                })
                .adapt(new FlowableBody<>())
                .map(listHttpData -> listHttpData.getData().getList())
                .onErrorReturnItem(new ArrayList<>());
    }
}
